library(survey)
library(dplyr)
library(ggplot2)
library(gridExtra)


# Chapter 9

### Figure 9.1
summary(factor(df$Q5A))
summary(factor(df$Q6A))
df2 <- df

# Important
df2$Q5A[df2$Q5A>3] <- NA
df2$Q5A[df2$Q5A==3] <- 0
df2$Q5A[df2$Q5A==2] <- 0.5
df2$Q5A[df2$Q5A==1] <- 1

df2$Q5B[df2$Q5B>3] <- NA
df2$Q5B[df2$Q5B==3] <- 0
df2$Q5B[df2$Q5B==2] <- 0.5
df2$Q5B[df2$Q5B==1] <- 1

df2$Q5C[df2$Q5C>3] <- NA
df2$Q5C[df2$Q5C==3] <- 0
df2$Q5C[df2$Q5C==2] <- 0.5
df2$Q5C[df2$Q5C==1] <- 1

df2$Q5D[df2$Q5D>3] <- NA
df2$Q5D[df2$Q5D==3] <- 0
df2$Q5D[df2$Q5D==2] <- 0.5
df2$Q5D[df2$Q5D==1] <- 1

df2$Q5E[df2$Q5E>3] <- NA
df2$Q5E[df2$Q5E==3] <- 0
df2$Q5E[df2$Q5E==2] <- 0.5
df2$Q5E[df2$Q5E==1] <- 1

df2$Q5F[df2$Q5F>3] <- NA
df2$Q5F[df2$Q5F==3] <- 0
df2$Q5F[df2$Q5F==2] <- 0.5
df2$Q5F[df2$Q5F==1] <- 1

df2$Q5G[df2$Q5G>3] <- NA
df2$Q5G[df2$Q5G==3] <- 0
df2$Q5G[df2$Q5G==2] <- 0.5
df2$Q5G[df2$Q5G==1] <- 1

df2$Q5H[df2$Q5H>3] <- NA
df2$Q5H[df2$Q5H==3] <- 0
df2$Q5H[df2$Q5H==2] <- 0.5
df2$Q5H[df2$Q5H==1] <- 1

colnames(df2[,25:32])
df2$IMPORTANT <- rowSums(df2[,25:32],na.rm = FALSE)/8
summary(df2$IMPORTANT)

# Useful
df2$Q6A[df2$Q6A>3] <- NA
df2$Q6A[df2$Q6A==3] <- 0
df2$Q6A[df2$Q6A==2] <- 0.5
df2$Q6A[df2$Q6A==1] <- 1

df2$Q6B[df2$Q6B>3] <- NA
df2$Q6B[df2$Q6B==3] <- 0
df2$Q6B[df2$Q6B==2] <- 0.5
df2$Q6B[df2$Q6B==1] <- 1

df2$Q6C[df2$Q6C>3] <- NA
df2$Q6C[df2$Q6C==3] <- 0
df2$Q6C[df2$Q6C==2] <- 0.5
df2$Q6C[df2$Q6C==1] <- 1

df2$Q6D[df2$Q6D>3] <- NA
df2$Q6D[df2$Q6D==3] <- 0
df2$Q6D[df2$Q6D==2] <- 0.5
df2$Q6D[df2$Q6D==1] <- 1

df2$Q6E[df2$Q6E>3] <- NA
df2$Q6E[df2$Q6E==3] <- 0
df2$Q6E[df2$Q6E==2] <- 0.5
df2$Q6E[df2$Q6E==1] <- 1

df2$Q6F[df2$Q6F>3] <- NA
df2$Q6F[df2$Q6F==3] <- 0
df2$Q6F[df2$Q6F==2] <- 0.5
df2$Q6F[df2$Q6F==1] <- 1

df2$Q6G[df2$Q6G>3] <- NA
df2$Q6G[df2$Q6G==3] <- 0
df2$Q6G[df2$Q6G==2] <- 0.5
df2$Q6G[df2$Q6G==1] <- 1

df2$Q6H[df2$Q6H>3] <- NA
df2$Q6H[df2$Q6H==3] <- 0
df2$Q6H[df2$Q6H==2] <- 0.5
df2$Q6H[df2$Q6H==1] <- 1


colnames(df2[,33:40])
df2$USEFUL <- rowSums(df2[,33:40], na.rm=FALSE)/8
summary(df2$USEFUL)

df2 <- df2[df2$Q11 < 5 & df2$P_ASSIGN1==1,]

w2_design <-
  svydesign(
    id = ~ 1,
    weights = ~ weight2,
    data = df2
  )

f.imp <- svyby(~ IMPORTANT, ~Q11, w2_design, svymean, na.rm = TRUE)
f.use <- svyby(~ USEFUL, ~Q11, w2_design, svymean, na.rm = TRUE)


# Important
g.imp <- ggplot(f.imp, aes(x=factor(Q11),y=IMPORTANT,label=round(IMPORTANT,digits=2)))+
  geom_col(width=0.5)+
  geom_text(size=3,position=position_dodge(1),vjust=-.5)+
  ylim(0,1)+
  scale_x_discrete(breaks=c(1,2,3,4),labels=c("A great deal",'Quite a lot',"Some",'Very little'))+
  xlab("")+
  ylab("Importance of Military Missions\n")

# Useful
g.use <- ggplot(f.use, aes(x=factor(Q11),y=USEFUL,label=round(USEFUL,digits=2)))+
  geom_col(width=0.5)+
  geom_text(size=3,position=position_dodge(1),vjust=-.5)+
  ylim(0,1)+
  scale_x_discrete(breaks=c(1,2,3,4),labels=c("A great deal",'Quite a lot',"Some",'Very little'))+
  xlab("")+
  ylab("Usefulness of Military Missions\n")

grid.arrange(g.imp,g.use,ncol=2)



########################################################################



### Figure 9.2
summary(factor(df$Q5A))
summary(factor(df$Q6A))
summary(factor(df$Q11))
df2 <- df

# Important
df2$Q5A[df2$Q5A>3] <- NA
df2$Q5A[df2$Q5A==3] <- 0
df2$Q5A[df2$Q5A==2] <- 0.5
df2$Q5A[df2$Q5A==1] <- 1

df2$Q5B[df2$Q5B>3] <- NA
df2$Q5B[df2$Q5B==3] <- 0
df2$Q5B[df2$Q5B==2] <- 0.5
df2$Q5B[df2$Q5B==1] <- 1

df2$Q5C[df2$Q5C>3] <- NA
df2$Q5C[df2$Q5C==3] <- 0
df2$Q5C[df2$Q5C==2] <- 0.5
df2$Q5C[df2$Q5C==1] <- 1

df2$Q5D[df2$Q5D>3] <- NA
df2$Q5D[df2$Q5D==3] <- 0
df2$Q5D[df2$Q5D==2] <- 0.5
df2$Q5D[df2$Q5D==1] <- 1

df2$Q5E[df2$Q5E>3] <- NA
df2$Q5E[df2$Q5E==3] <- 0
df2$Q5E[df2$Q5E==2] <- 0.5
df2$Q5E[df2$Q5E==1] <- 1

df2$Q5F[df2$Q5F>3] <- NA
df2$Q5F[df2$Q5F==3] <- 0
df2$Q5F[df2$Q5F==2] <- 0.5
df2$Q5F[df2$Q5F==1] <- 1

df2$Q5G[df2$Q5G>3] <- NA
df2$Q5G[df2$Q5G==3] <- 0
df2$Q5G[df2$Q5G==2] <- 0.5
df2$Q5G[df2$Q5G==1] <- 1

df2$Q5H[df2$Q5H>3] <- NA
df2$Q5H[df2$Q5H==3] <- 0
df2$Q5H[df2$Q5H==2] <- 0.5
df2$Q5H[df2$Q5H==1] <- 1

colnames(df2) # 25:32

df2$REAL <- rowSums(df2[,c(25,32)],na.rm=FALSE)/2 # Q5A+Q5H
df2$HUMAN <- rowSums(df2[,c(28,30)],na.rm=FALSE)/2 # Q5D+Q5F
df2$SECURITY <- rowSums(df2[,c(29,31)],na.rm=FALSE)/2 # Q5E+Q5G
df2$DOMESTIC <- rowSums(df2[,c(26,27)],na.rm=FALSE)/2 # Q5B+Q5C

df2 <- df2[df2$Q11 < 5 & df2$P_ASSIGN1==1,]

w2_design <-
  svydesign(
    id = ~ 1,
    weights = ~ weight2,
    data = df2
  )

f.real <- svyby(~ REAL, ~Q11, w2_design, svymean, na.rm = TRUE)
f.hum <- svyby(~ HUMAN, ~Q11, w2_design, svymean, na.rm = TRUE)
f.sec <- svyby(~ SECURITY, ~Q11, w2_design, svymean, na.rm = TRUE)
f.dom <- svyby(~ DOMESTIC, ~Q11, w2_design, svymean, na.rm = TRUE)

# Realpolitik
g.real <- ggplot(f.real, aes(x=factor(Q11),y=REAL,label=round(REAL,digits=2)))+
  geom_col(width=0.5)+
  geom_text(size=3,position=position_dodge(1),vjust=-.5)+
  ylim(0,1)+
  scale_x_discrete(breaks=c(1,2,3,4),labels=c("A great deal",'Quite a lot',"Some",'Very little'))+
  xlab("")+
  ylab("Importance of Realpolitik Missions\n")

# Humanitarian
g.hum <- ggplot(f.hum, aes(x=factor(Q11),y=HUMAN,label=round(HUMAN,digits=2)))+
  geom_col(width=0.5)+
  geom_text(size=3,position=position_dodge(1),vjust=-.5)+
  ylim(0,1)+
  scale_x_discrete(breaks=c(1,2,3,4),labels=c("A great deal",'Quite a lot',"Some",'Very little'))+
  xlab("")+
  ylab("Importance of Humanitarian Missions\n")

# Homeland
g.sec <- ggplot(f.sec, aes(x=factor(Q11),y=SECURITY,label=round(SECURITY,digits=2)))+
  geom_col(width=0.5)+
  geom_text(size=3,position=position_dodge(1),vjust=-.5)+
  ylim(0,1)+
  scale_x_discrete(breaks=c(1,2,3,4),labels=c("A great deal",'Quite a lot',"Some",'Very little'))+
  xlab("")+
  ylab("Importance of Homeland Security\n")

# Domestic
g.dom <- ggplot(f.dom, aes(x=factor(Q11),y=DOMESTIC,label=round(DOMESTIC,digits=2)))+
  geom_col(width=0.5)+
  geom_text(size=3,position=position_dodge(1),vjust=-.5)+
  ylim(0,1)+
  scale_x_discrete(breaks=c(1,2,3,4),labels=c("A great deal",'Quite a lot',"Some",'Very little'))+
  xlab("")+
  ylab("Importance of Domestic Social Work\n")

grid.arrange(g.real,g.hum,g.sec,g.dom,ncol=2,nrow=2)



########################################################################



### Figure 9.3
summary(factor(df$Q5B))
summary(factor(df$Q5C))
df2 <- df

# Important
df2$Q5B[df2$Q5B>3] <- NA
df2$Q5B[df2$Q5B==3] <- 0
df2$Q5B[df2$Q5B==2] <- 0.5
df2$Q5B[df2$Q5B==1] <- 1

df2$Q5C[df2$Q5C>3] <- NA
df2$Q5C[df2$Q5C==3] <- 0
df2$Q5C[df2$Q5C==2] <- 0.5
df2$Q5C[df2$Q5C==1] <- 1

colnames(df2[,c(26,27)]) # 26,27

df2 <- df2[df2$Q11 < 5 & df2$P_ASSIGN1==1,]

w2_design <-
  svydesign(
    id = ~ 1,
    weights = ~ weight2,
    data = df2
  )

f.Q5B <- svyby(~ Q5B, ~Q11, w2_design, svymean, na.rm = TRUE)
f.Q5C <- svyby(~ Q5C, ~Q11, w2_design, svymean, na.rm = TRUE)

# Redressing Discrimination
g.5B <- ggplot(f.Q5B, aes(x=factor(Q11),y=Q5B,label=round(Q5B,digits=2)))+
  geom_col(width=0.5)+
  geom_text(size=3,position=position_dodge(1),vjust=-.5)+
  ylim(0,1)+
  scale_x_discrete(breaks=c(1,2,3,4),labels=c("A great deal",'Quite a lot',"Some",'Very little'))+
  xlab("")+
  ylab("Importance of Military in Redressing Discrimination\n")

# Disaster Relief
g.5C <- ggplot(f.Q5C, aes(x=factor(Q11),y=Q5C,label=round(Q5C,digits=2)))+
  geom_col(width=0.5)+
  geom_text(size=3,position=position_dodge(1),vjust=-.5)+
  ylim(0,1)+
  scale_x_discrete(breaks=c(1,2,3,4),labels=c("A great deal",'Quite a lot',"Some",'Very little'))+
  xlab("")+
  ylab("Importance of Disaster Relief Missions\n")

grid.arrange(g.5B,g.5C,ncol=2)



########################################################################



### Figure 9.4
summary(factor(df$Q5A))
summary(factor(df$Q6A))
df2 <- df[df$Q11<5,]

df2$Q11T <- NA
df2$Q11T[df2$Q11>2] <- 0
df2$Q11T[df2$Q11<3] <- 1

# Important
df2$Q5A[df2$Q5A>3] <- NA
df2$Q5A[df2$Q5A==3] <- 0
df2$Q5A[df2$Q5A==2] <- 0.5
df2$Q5A[df2$Q5A==1] <- 1

df2$Q5B[df2$Q5B>3] <- NA
df2$Q5B[df2$Q5B==3] <- 0
df2$Q5B[df2$Q5B==2] <- 0.5
df2$Q5B[df2$Q5B==1] <- 1

df2$Q5C[df2$Q5C>3] <- NA
df2$Q5C[df2$Q5C==3] <- 0
df2$Q5C[df2$Q5C==2] <- 0.5
df2$Q5C[df2$Q5C==1] <- 1

df2$Q5D[df2$Q5D>3] <- NA
df2$Q5D[df2$Q5D==3] <- 0
df2$Q5D[df2$Q5D==2] <- 0.5
df2$Q5D[df2$Q5D==1] <- 1

df2$Q5E[df2$Q5E>3] <- NA
df2$Q5E[df2$Q5E==3] <- 0
df2$Q5E[df2$Q5E==2] <- 0.5
df2$Q5E[df2$Q5E==1] <- 1

df2$Q5F[df2$Q5F>3] <- NA
df2$Q5F[df2$Q5F==3] <- 0
df2$Q5F[df2$Q5F==2] <- 0.5
df2$Q5F[df2$Q5F==1] <- 1

df2$Q5G[df2$Q5G>3] <- NA
df2$Q5G[df2$Q5G==3] <- 0
df2$Q5G[df2$Q5G==2] <- 0.5
df2$Q5G[df2$Q5G==1] <- 1

df2$Q5H[df2$Q5H>3] <- NA
df2$Q5H[df2$Q5H==3] <- 0
df2$Q5H[df2$Q5H==2] <- 0.5
df2$Q5H[df2$Q5H==1] <- 1

colnames(df2) # 25:32

df2$REAL <- rowSums(df2[,c(25,32)],na.rm=FALSE)/2 # Q5A+Q5H
df2$HUMAN <- rowSums(df2[,c(28,30)],na.rm=FALSE)/2 # Q5D+Q5F
df2$SECURITY <- rowSums(df2[,c(29,31)],na.rm=FALSE)/2 # Q5E+Q5G
df2$DOMESTIC <- rowSums(df2[,c(26,27)],na.rm=FALSE)/2 # Q5B+Q5C

df2 <- df2[df2$Q11 < 5 & df2$P_ASSIGN1==1,]

w2_design <-
  svydesign(
    id = ~ 1,
    weights = ~ weight2,
    data = df2
  )

f.real <- svyby(~ REAL, ~Q11T+party, w2_design, svymean, na.rm = TRUE)
f.hum <- svyby(~ HUMAN, ~Q11T+party, w2_design, svymean, na.rm = TRUE)
f.sec <- svyby(~ SECURITY, ~Q11T+party, w2_design, svymean, na.rm = TRUE)
f.dom <- svyby(~ DOMESTIC, ~Q11T+party, w2_design, svymean, na.rm = TRUE)

# Realpolitik
g.real <- ggplot(f.real, aes(x=factor(party),y=REAL,fill=factor(Q11T),label=round(REAL,digits=2)))+
  geom_col(position = position_dodge(),width=0.5)+
  geom_text(size=3,position=position_dodge(1),vjust=-.5)+
  ylim(0,1)+
  theme(legend.position = "null")+
  scale_x_discrete(labels=c("Democrat",'Independent',"Republican"))+
  xlab("")+
  ylab("Importance of Realpolitik Missions\n")

# Humanitarian
g.hum <- ggplot(f.hum, aes(x=factor(party),y=HUMAN,fill=factor(Q11T),label=round(HUMAN,digits=2)))+
  geom_col(position = position_dodge(),width=0.5)+
  geom_text(size=3,position=position_dodge(1),vjust=-.5)+
  ylim(0,1)+
  theme(legend.position = "null")+
  scale_x_discrete(labels=c("Democrat",'Independent',"Republican"))+
  xlab("")+
  ylab("Importance of Humanitarian Missions\n")

# Homeland
g.sec <- ggplot(f.sec, aes(x=factor(party),y=SECURITY,fill=factor(Q11T),label=round(SECURITY,digits=2)))+
  geom_col(position = position_dodge(),width=0.5)+
  geom_text(size=3,position=position_dodge(1),vjust=-.5)+
  ylim(0,1)+ 
  theme(legend.position = "null")+
  scale_x_discrete(labels=c("Democrat",'Independent',"Republican"))+
  xlab("")+
  ylab("Importance of Homeland Security\n")

# Domestic
g.dom <- ggplot(f.dom, aes(x=factor(party),y=DOMESTIC,fill=factor(Q11T),label=round(DOMESTIC,digits=2)))+
  geom_col(position = position_dodge(),width=0.5)+
  geom_text(size=3,position=position_dodge(1),vjust=-.5)+
  ylim(0,1)+
  theme(legend.position = 'null')+
  scale_x_discrete(labels=c("Democrat",'Independent',"Republican"))+
  xlab("")+
  ylab("Importance of Domestic Social Work\n")

grid.arrange(g.real,g.hum,g.sec,g.dom,ncol=2,nrow=2)



########################################################################



### Figure 9.5
summary(factor(df$Q5D))
summary(factor(df$Q5F))
df2 <- df[df$Q11<5,]

df2$Q11T <- NA
df2$Q11T[df2$Q11>2] <- 0
df2$Q11T[df2$Q11<3] <- 1

# Important
df2$Q5D[df2$Q5D>3] <- NA
df2$Q5D[df2$Q5D==3] <- 0
df2$Q5D[df2$Q5D==2] <- 0.5
df2$Q5D[df2$Q5D==1] <- 1

df2$Q5F[df2$Q5F>3] <- NA
df2$Q5F[df2$Q5F==3] <- 0
df2$Q5F[df2$Q5F==2] <- 0.5
df2$Q5F[df2$Q5F==1] <- 1

df2 <- df2[df2$P_ASSIGN1==1,]

w2_design <-
  svydesign(
    id = ~ 1,
    weights = ~ weight2,
    data = df2
  )

f.5D <- svyby(~ Q5D, ~Q11T+party, w2_design, svymean, na.rm = TRUE)
f.5F <- svyby(~ Q5F, ~Q11T+party, w2_design, svymean, na.rm = TRUE)

# Humanitarian Missions
g.5D <- ggplot(f.5D, aes(x=factor(party),y=Q5D,fill=factor(Q11T),label=round(Q5D,digits=2)))+
  geom_col(position = position_dodge(), width=0.5)+
  geom_text(size=3,position=position_dodge(1),vjust=-.5)+
  ylim(0,1)+
  theme(legend.position = "null")+
  scale_x_discrete(labels=c("Democrat",'Independent',"Republican"))+
  xlab("")+
  ylab("Importance of Humanitarian Missions Abroad\n")

# Civil War
g.5F <- ggplot(f.5F, aes(x=factor(party),y=Q5F,fill=factor(Q11T),label=round(Q5F,digits=2)))+
  geom_col(position = position_dodge(), width=0.5)+
  geom_text(size=3,position=position_dodge(1),vjust=-.5)+
  ylim(0,1)+
  theme(legend.position = "null")+
  scale_x_discrete(labels=c("Democrat",'Independent',"Republican"))+
  xlab("")+
  ylab("Importance of Civil War Intervention Missions\n")

grid.arrange(g.5D,g.5F,ncol=2)



########################################################################



### Figure 9.6
summary(factor(df$Q6D))
summary(factor(df$Q6C))
df2 <- df[df$Q11<5,]

df2$Q11T <- NA
df2$Q11T[df2$Q11>2] <- 0
df2$Q11T[df2$Q11<3] <- 1

# Important
df2$Q6D[df2$Q6D>3] <- NA
df2$Q6D[df2$Q6D==3] <- 0
df2$Q6D[df2$Q6D==2] <- 0.5
df2$Q6D[df2$Q6D==1] <- 1

df2$Q6C[df2$Q6C>3] <- NA
df2$Q6C[df2$Q6C==3] <- 0
df2$Q6C[df2$Q6C==2] <- 0.5
df2$Q6C[df2$Q6C==1] <- 1

df2 <- df2[df2$P_ASSIGN1==1,]

w2_design <-
  svydesign(
    id = ~ 1,
    weights = ~ weight2,
    data = df2
  )

f.6D <- svyby(~ Q6D, ~Q11T+party, w2_design, svymean, na.rm = TRUE)
f.6C <- svyby(~ Q6C, ~Q11T+party, w2_design, svymean, na.rm = TRUE)

# Humanitarian Missions
g.6D <- ggplot(f.6D, aes(x=factor(party),y=Q6D,fill=factor(Q11T),label=round(Q6D,digits=2)))+
  geom_col(position = position_dodge(1), width=0.5)+
  geom_text(size=3,position=position_dodge(1),vjust=-.5)+
  ylim(0,1)+
  theme(legend.position = "null")+
  scale_x_discrete(labels=c("Democrat",'Independent',"Republican"))+
  xlab("")+
  ylab("Usefulness of Humanitarian Missions Abroad\n")

# Civil War
g.6C <- ggplot(f.6C, aes(x=factor(party),y=Q6C,fill=factor(Q11T),label=round(Q6C,digits=2)))+
  geom_col(position = position_dodge(1), width=0.5)+
  geom_text(size=3,position=position_dodge(1),vjust=-.5)+
  ylim(0,1)+
  theme(legend.position = "null")+
  scale_x_discrete(labels=c("Democrat",'Independent',"Republican"))+
  xlab("")+
  ylab("Usefullness of Disaster Relief Missions\n")

grid.arrange(g.6D,g.6C,ncol=2)



########################################################################



### Figure 9.7
summary(factor(df$Q21))
summary(factor(df$Q25A))
summary(factor(df$Q11T))
summary(factor(mil_conf.df$Q8a))

# DVs
# Wave 2
df2 <- df[df$Q11<5,]

df2$Q21A <- NA
df2$Q21A[df2$Q21 > 2 & df2$Q21 < 6] <- 0
df2$Q21A[df2$Q21 < 3] <- 1

df2$Q25AA <- NA
df2$Q25AA[df2$Q25A > 2 & df2$Q25A < 6] <- 0
df2$Q25AA[df2$Q25A < 3] <- 1

df2 <- df2[df2$P_ASSIGN1==1,]


# Wave 1
summary(factor(mil_conf.df$Q42A))

mil_conf.df2 <- mil_conf.df

mil_conf.df2$Q42A2 <- NA
mil_conf.df2$Q42A2[mil_conf.df2$Q42A < 6] <- 0
mil_conf.df2$Q42A2[mil_conf.df2$Q42A < 3] <- 1


# Survey Designs
w2_design <-
  svydesign(
    id = ~ 1,
    weights = ~ weight2,
    data = df2
  )

w1_design <-
  svydesign(
    id = ~ 1,
    weights = ~ weight,
    data = mil_conf.df2
  )

f.Q21A <- svyby(~ Q21A, ~Q11T+party, w2_design, svymean, na.rm = TRUE)
f.Q25AA <- svyby(~ Q25AA, ~Q11T+party, w2_design, svymean, na.rm = TRUE)
f.Q42A2 <- svyby(~ Q42A2, ~Q8a+party, w1_design, svymean, na.rm = TRUE)

# 
g.Q21A <- ggplot(f.Q21A, aes(x=factor(party),y=Q21A,fill=factor(Q11T),label=round(Q21A,digits=2)))+
  geom_col(position = position_dodge(1), width=0.5)+
  geom_text(size=3,position=position_dodge(1),vjust=-.5)+
  ylim(0,1)+
  theme(legend.position = "null")+
  scale_x_discrete(labels=c("Democrat",'Independent',"Republican"))+
  xlab("")+
  ylab("Percent Support for Iran Strikes\n")

# Civil War
g.Q25AA <- ggplot(f.Q25AA, aes(x=factor(party),y=Q25AA,fill=factor(Q11T),label=round(Q25AA,digits=2)))+
  geom_col(position = position_dodge(1), width=0.5)+
  geom_text(size=3,position=position_dodge(1),vjust=-.5)+
  ylim(0,1)+
  theme(legend.position = "null")+
  scale_x_discrete(labels=c("Democrat",'Independent',"Republican"))+
  xlab("")+
  ylab("Percent Support for Insurrection Act\n")

g.Q42A2 <- ggplot(f.Q42A2, aes(x=factor(party),y=Q42A2,fill=factor(Q8a),label=round(Q42A2,digits=2)))+
  geom_col(position = position_dodge(1), width=0.5)+
  geom_text(size=3,position=position_dodge(1),vjust=-.5)+
  ylim(0,1)+
  theme(legend.position = "null")+
  scale_x_discrete(labels=c("Democrat",'Independent',"Republican"))+
  xlab("")+
  ylab("Percent Support for Border Mission\n")

grid.arrange(g.Q21A,g.Q25AA, g.Q42A2,ncol=3)



